package com.xuecheng.content.controller;


import com.xuecheng.api.content.CourseRelatedTeacherAPI;
import com.xuecheng.api.media.model.CourseTeacherDTO;
import com.xuecheng.content.service.CourseTeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程-教师关系表 前端控制器
 * </p>
 *
 * @author itcast
 * @since 2019-11-05
 */
@Slf4j
@RestController
@RequestMapping(path = "courseTeacher")
public class CourseTeacherController implements CourseRelatedTeacherAPI {

    @Autowired
    private CourseTeacherService courseTeacherService;


    @GetMapping(path = "list/{courseBaseId}")
    public List<CourseTeacherDTO> courseTeachers(@PathVariable Long courseBaseId) {
        return courseTeacherService.courseTeacherList(courseBaseId, null);
    }


    @PostMapping
    public CourseTeacherDTO addCourseTeachers(@RequestBody CourseTeacherDTO teacherDTO) {
        return courseTeacherService.addCourseTeachers(teacherDTO);
    }


    @DeleteMapping(path = "course/{courseBaseId}/{courseTeacherId}")
    public boolean delCourseTeachers(@PathVariable Long courseBaseId, @PathVariable Long courseTeacherId) {
        return courseTeacherService.delCourseTeachers(courseBaseId, courseTeacherId);
    }

}
